﻿using System;

namespace ICommonLibrary.Json {

    public class JsonNumber : JsonValue {

        public double Value { get; set; }

        public JsonNumber(double value) {
            Value = value;
        }

        public override bool Equals(object other) {
            var d = other as JsonNumber;
            if (d == null) {
                return false;
            }
            return Math.Abs(Value - d.Value) < 0.001;
        }

        public override int GetHashCode() {
            return Value.GetHashCode();
        }

        public override JsonNumber IsNumber() {
            return this;
        }

        public override string ToJsonString() {
            return Value.ToString();
        }
    }
}